package com.hnkywl.sts.service.cggl;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hnkywl.sts.dao.cggl.GlfyDao;
import net.ruixin.orm.hibernate.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: 灵韵
 * Date: 13-9-20
 * Time: 下午4:16
 * To change this template use File | Settings | File Templates.
 */
@Service
public class GlfyService {

    private GlfyDao glfyDao;

    public String findAllGlfyList(String djh,String ywlx,Long fylbId,Long sydwId,String jszt,Long cgdwId,Date zdsjStart,Date zdsjEnd,int pageNo, int rows) {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        Page glfyPage = this.glfyDao.findAllGlfyList(djh,ywlx,fylbId,sydwId,jszt,cgdwId,zdsjStart,zdsjEnd,pageNo, rows);
        String glfyJson = gson.toJson(glfyPage.getResult());
        return "{\"total\":" + glfyPage.getTotalCount() + ",\"rows\":" + glfyJson + "}";
    }


    @Autowired
    public void setGlfyDao(GlfyDao glfyDao) {
        this.glfyDao = glfyDao;
    }
}
